/**
 * 路由配置
 */

// 基础路由
export const basicRoutes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: '登录',
      hidden: true
    }
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/exception/404.vue'),
    meta: {
      title: '404',
      hidden: true
    }
  }
]

// 主要路由
export const mainRoutes = [
  {
    path: '/',
    name: 'Root',
    redirect: '/dashboard',
    component: () => import('@/layouts/BasicLayout.vue'),
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: {
          title: '首页',
          icon: 'HomeOutlined',
          affix: true,
          keepAlive: true
        }
      }
    ]
  },
  {
    path: '/system',
    name: 'System',
    component: () => import('@/layouts/BasicLayout.vue'),
    redirect: '/system/user',
    meta: {
      title: '系统管理',
      icon: 'SettingOutlined',
      orderNo: 1
    },
    children: [
      {
        path: 'user',
        name: 'SystemUser',
        component: () => import('@/views/system/user/index.vue'),
        meta: {
          title: '用户管理',
          icon: 'UserOutlined',
          keepAlive: true
        }
      },
      {
        path: 'role',
        name: 'SystemRole',
        component: () => import('@/views/system/role/index.vue'),
        meta: {
          title: '角色管理',
          icon: 'TeamOutlined',
          keepAlive: true
        }
      },
      {
        path: 'menu',
        name: 'SystemMenu',
        component: () => import('@/views/system/menu/index.vue'),
        meta: {
          title: '菜单管理',
          icon: 'MenuOutlined',
          keepAlive: true
        }
      }
    ]
  }
]

// 重定向到404页面
export const redirectRoute = {
  path: '/:pathMatch(.*)*',
  redirect: '/404',
  meta: {
    hidden: true
  }
}

// 合并所有路由
export const routes = [
  ...basicRoutes,
  ...mainRoutes,
  redirectRoute
]
